package com.forum.controller.admin;

import com.forum.result.Result;
import com.forum.service.ReportService;
import com.forum.vo.FeedBackVO;
import com.forum.vo.NewUserVO;
import com.forum.vo.SexRatioVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@Api(tags = "数据可视化")
@RestController
@RequestMapping("/admin/report")
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;

    @ApiOperation("新增用户数量")
    @PostMapping("/newUser")
    public Result<NewUserVO> NewUser(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("新增人员查询开始{},{}",begin,end);
        NewUserVO newUserVO= reportService.NewUser(begin,end);
        log.info("新增人员{}",newUserVO);
        return Result.success(newUserVO);
    }
    @ApiOperation("用户性别比例")
    @GetMapping("/sexRatio")
    public Result<SexRatioVO> sexRatio(){
        SexRatioVO sexRatioVO=reportService.sexRatio();
        return Result.success(sexRatioVO);
    }

    @ApiOperation("反馈信息数量")
    @PostMapping("/feedBack")
    public Result<FeedBackVO> feedBack(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("新增人员查询开始{},{}",begin,end);
        FeedBackVO feedBackVO = reportService.feedBack(begin,end);
        return Result.success(feedBackVO);
    }
}
